package edu.lsnu.equipment_management_system.mapper.insert;

import edu.lsnu.equipment_management_system.pojo.po.entity.EquipmentInformationTablePo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

/**
 * @author mzy
 * @Description 插入JBXX_SB
 * @date 2018/11/20
 */
public interface EquipmentInformationTableMapper {

    @Insert("insert into JBXX_SB (SBBH, SBMC, SBLY, SBLBDM, XH, GG, SL, DJ, CHPHM, GHDW, JHRQ, YT, CCCJ,\n" +
            "                     ZZH, BZ, FJMC, FJGG, FJSL, SYDWFZR, CGR, YSR, JZR, LYVMBDM)\n" +
            "values (#{equipmentNo},\n" +
            "        #{equipmentName},\n" +
            "        #{equipmentSource},\n" +
            "        #{equipmentCategoryNo},\n" +
            "        #{type},\n" +
            "        #{guiGe},\n" +
            "        #{number},\n" +
            "        #{price},\n" +
            "        #{shippingNo},\n" +
            "        #{deliveryUnit},\n" +
            "        #{purchaseDate},\n" +
            "        #{application},\n" +
            "        #{manufacturer},\n" +
            "        #{manufacturerNo},\n" +
            "        #{remark},\n" +
            "        #{attachmentName},\n" +
            "        #{attachmentGuiGe},\n" +
            "        #{attachmentNumber},\n" +
            "        #{leaderOfUserUnit},\n" +
            "        #{purchaser},\n" +
            "        #{acceptor},\n" +
            "        #{bookkeeper},\n" +
            "        #{utilizationTemplateNo}\n" +
            "        )")
    int insertEquipmentInformationTable(EquipmentInformationTablePo equipmentInformationTablePo);

    /**
     * @Description 确保设备编号不存在
     * @author mzy
     * @time 2018-11-22
     * @see
     * @return   int
     * @params  [equipmentNo]
     */
    @Select("select count(JBXX_SB.SBBH) from JBXX_SB where JBXX_SB.SBBH = #{equipmentNo}")
    int existEquipment(String equipmentNo); // 20020152
}
